﻿Public Class Frmsposta_in_modifica
    Dim SORGENTE As ListBox.SelectedObjectCollection
    Dim MODIFICA As String
    Dim descrizione As String
    Dim filename As String
    Dim estensione As String




    Public Sub crea_sorgente(ByVal lista As ListBox.SelectedObjectCollection)

        SORGENTE = lista

    End Sub

    Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim DIRECTORY1 As String
        descrizione = TextBox1.Text
        descrizione = descrizione.ToUpper
        If descrizione.Contains("/") Then
            descrizione = descrizione.Replace("/", "_")
        End If
        If descrizione.Contains("\") Then
            descrizione = descrizione.Replace("\", "_")
        End If

        For Each FILE In SORGENTE

            filename = My.Computer.FileSystem.GetName(FILE)
            estensione = filename.Remove(0, filename.Count - 4)
            filename = filename.Remove(filename.Count - 4, 4)
            comp_pdf.dati_stampa.INS_MODIFICA(descrizione, FILE)
            directory1 = filename.Remove(1, filename.Length - 1)

            If Not My.Computer.FileSystem.FileExists("\\Lafer2k3\uff_tec\Z_PDF_modifica_PROE\" & directory1 & "\" & filename & estensione) Then
                My.Computer.FileSystem.CopyFile(FILE, "\\Lafer2k3\uff_tec\Z_PDF_modifica_PROE\" & directory1 & "\" & filename & estensione)
                My.Computer.FileSystem.DeleteFile(FILE)
            End If
        Next



        Me.Close()

        Form1.Button1_Click(sender, e)
    End Sub

    Private Sub Frmsposta_in_modifica_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Text = ""

    End Sub


End Class